<!--
 * @message: 面包屑组件
-->
<template>
  <div class="breadcrumb-box">
    <Breadcrumb>
      <BreadcrumbItem v-for="(item2, index2) in breadlists" :key="index2" :to="{path: item2.path}">{{item2.title}}</BreadcrumbItem>
    </Breadcrumb>
  </div>
</template>
<script>
export default {
  data () {
    return {
      breadlists: []
    }
  },
  created () {
    this.getBread()
  },
  watch: {
    $route () {
      this.getBread()
    }
  },
  mounted () {
  },
  methods: {
    getBread () {
      const breadlist = []
      this.$route.matched.forEach(item => {
        if (item.meta.data) {
          breadlist.push(item.meta.data)
        }
      })
      this.breadlists = []
      breadlist.forEach(item2 => {
        item2.forEach(item3 => {
          this.breadlists.push(item3)
        })
      })
    }
  }
}
</script>

<style scoped>
  .breadcrumb-box{
    width: 100%;
    margin-bottom: 10px;
  }
</style>
